package com.artPreter.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.artPreter.pojo.Artist;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.artPreter.pojo.dto.ArtistName;
import com.artPreter.pojo.dto.ItemBase;
import com.artPreter.pojo.vos.page.RoomPageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 艺术家表 Mapper 接口
 * </p>
 *
 * @author jarvis
 * @since 2024-11-14
 */
@Mapper
public interface ArtistMapper extends BaseMapper<Artist> {


    @Select("SELECT a.*, (select COUNT(1) FROM jv_artist_relative br WHERE br.status = 1 and br.artist_id = a.artist_id ) as num  " +
            "FROM jv_artist a " +
            "JOIN jv_artist_relative ar ON a.artist_id = ar.artist_id " +
            "JOIN jv_depart d ON ar.depart_id = d.depart_id " +
            " ${ew.customSqlSegment} group by a.id  ")
    IPage<Artist> getPageWithDepart(IPage<Artist> artistIPage, @Param(Constants.WRAPPER) Wrapper wrapper);

    @Select("select a.*, (select COUNT(1) FROM jv_artist_relative br WHERE br.status = 1 and br.artist_id = a.artist_id ) as num  from jv_artist a ${ew.customSqlSegment}")
    IPage<Artist> getPage(IPage<Artist> artistIPage, @Param(Constants.WRAPPER) Wrapper wrapper);


    @Select("select artist_id as id , name as name, first_py as firstPy from jv_artist ${ew.customSqlSegment} ")
    List<ItemBase> getListByFirstPy(@Param(Constants.WRAPPER) Wrapper wrapper);

    @Select(" select b.*,s.sort as ctSort  FROM jv_content_artist_relative s left join jv_artist b on s.artist_id = b.artist_id ${ew.customSqlSegment} ")
    IPage<Artist> getRelatedArtistPageList(IPage<Artist> artistIPage, @Param(Constants.WRAPPER) Wrapper wrapper);
}
